package ar.uba.fi.taller2.ftrs.query;

import java.io.StringReader;
import java.util.ArrayList;
import java_cup.runtime.Symbol;

public class QueryParser {
	public static ArrayList parse(String query, Object Index ) throws Exception {
	    query+="\n";
	    StringReader read= new StringReader(query);
	    Yylex scanner = new Yylex(read);     // create scanner    
	    parser parser = new parser(scanner); // create parser
	    ArrayList resultado = new ArrayList();
	    try { 
	    	Symbol s = parser.parse();
	        Tquery q = (Tquery)s.value;
	        resultado = q.interpret();
	    }    
	    catch (Exception e) { 
	      e.printStackTrace(); 
	    }    
	    return resultado;
	  }
			  
}
